package org.JQbitorrentClinet.impl.V283;

import org.JQbitorrentClinet.QBitorrentConnectionInfo;
import org.JQbitorrentClinet.base.BaseProxy;
import org.JQbitorrentClinet.interfaces.TransferInfoProxy;
import org.JQbitorrentClinet.request.transferinfo.*;
import org.JQbitorrentClinet.pojo.transfer.GlobalTransferInfo;

public class TransferInfoProxy_V2_8_3 extends BaseProxy implements TransferInfoProxy {

    public TransferInfoProxy_V2_8_3(QBitorrentConnectionInfo connectionInfo) {
        super(connectionInfo);
    }

    @Override
    public GlobalTransferInfo getGlobalTransferInfo() {
        login();
        GetGlobalTransferInfoParam param = GetGlobalTransferInfoParam.builder().build();
        return process(param);
    }

    @Override
    public Boolean getAlternativeSpeedLimitsEnabled() {
        login();
        GetAlternativeSpeedLimitsStateParam param = GetAlternativeSpeedLimitsStateParam.builder().build();
        Long res = process(param);
        return res == 1;
    }

    @Override
    public Boolean toggleAlternativeSpeedLimits() {
        login();
        String result = process(ToggleAlternativeSpeedLimitsParam.builder().build());
        return result.equals("Ok.");
    }

    @Override
    public Long getGlobalDownloadSpeed() {
        login();
        return process(GetGlobalDownloadLimitParam.builder().build());
    }

    @Override
    public Boolean setGlobalDownloadLimit(Long limit) {
        login();
        String result = process(SetGlobalDownLimitParam.builder().limit(limit).build());
        return result.equals("");
    }

    @Override
    public Long getGlobalUploadSpeed() {
        login();
        return process(new GetGlobalUploadLimit());
    }

    @Override
    public Boolean setGlobalUploadLimit(Long limit) {
        login();
        String result = process(SetGlobalUploadLimitParam.builder().limit(limit).build());
        return result.equals("");
    }

    @Override
    public Boolean BanPeers(BanPeersParam param) {
        login();
        String result = process(param);
        return result.equals("Ok.");
    }
}
